package com.zhongke.cotrun.mapper;

import com.zhongke.cotrun.model.pojo.UserIntegralHistory;
import com.zhongke.cotrun.model.pojo.UserIntegralHistoryVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.awt.*;
import java.util.List;

public interface UserIntegralHistoryMapper {
    /**
     * 新增积分记录
     *
     * @param userIntegralHistory
     * @return
     */

    @Insert("INSERT INTO `user_integral_history` (`intergral_name_id`, `integral_value`, `create_time`, `user_id`,`integral_record_id`,`rank_one_of`,`rank_two_of`,`history_explain`) VALUES (#{intergralNameId}, #{integralValue}, NOW(), #{userId},#{integralRecordId},#{rankOneOf},#{rankTwoOf},#{historyExplain})")
    public boolean insertUserIntegralHistory(UserIntegralHistory userIntegralHistory);


    /**
     * 根据用户的id查询历史记录
     *
     * @param userId
     * @return
     */
    @Select("SELECT * FROM user_integral_history WHERE user_id=#{userId} ORDER BY create_time DESC")
    public List<UserIntegralHistoryVo> selectUserIntegralHistoryByUserId(Integer userId);

    /**
     * 查看所有的积分的记录
     *
     * @return
     */
    @Select("SELECT * FROM user_integral_history ORDER BY create_time DESC")
    public List<UserIntegralHistoryVo> selectAllUserIntegralHistory();

    /**
     * 查询近三个月的数据
     *
     * @param userId
     * @return
     */
    @Select("select * from user_integral_history where create_time>DATE_SUB(CURDATE(), INTERVAL 3 MONTH) and user_id=#{userId} ORDER BY create_time DESC ")
    public List<UserIntegralHistoryVo> selectThreeUserIntegralHistoryByUserId(Integer userId);

    /**
     * 按条件搜索历史记录
     * @return
     * userId
     * rankOneOf
     *
     */
    public List<UserIntegralHistoryVo> selectIntegralHistoryByCndition(UserIntegralHistory userIntegralHistory);

    /**
     * 后台根据条件搜索所有的历史记录
     * @param userIntegralHistory
     * @return
     */

    public List<UserIntegralHistoryVo> adminSelectHistory(UserIntegralHistory userIntegralHistory);

}
